
<?php
$ip = '127.0.0.1';
$port = '12345';
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($socket, $ip, $port);


while (true) {
	socket_recvfrom($socket, $content, 1024, 0, $ip, $port);
	if (!empty($content)){
		file_put_contents('data.txt', $content."\n", FILE_APPEND);
	}
}
socket_close($socket);
?>
